package cn.gjculture.shopping.api.service.impl;

import cn.gjculture.shopping.api.dao.IdDao;
import cn.gjculture.shopping.api.entity.Id;
import cn.gjculture.shopping.api.service.IdService;
import cn.gjculture.shopping.api.util.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class IdServiceImpl implements IdService {

    @Autowired
    IdDao idDao;

    @Override
    public Long queryCustomerNo() {
        Long id=queryId();
        return Long.valueOf("10"+id);
    }

    @Override
    public Long queryOrderNo() {
        Long id=queryId();
        String date= DateUtils.getDate(DateUtils.YYYY_MM_DD_HH_MM_SS);
        return Long.valueOf(date+"0"+id);
    }

    Long queryId(){
        Id id=new Id();
        idDao.query(id);
        return id.getId();
    }
}
